package MsgSystem;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jivesoftware.smackx.filetransfer.FileTransferRequest;
import org.jivesoftware.smackx.filetransfer.FileTransferListener;

//This class implements the receive connections and receive the file of the source
public class ReceiveMessages extends Thread implements FileTransferListener {

    private static final Log LOGGER = LogFactory.getLog("common");
    ImpInstantMessage itm = null;
    TransferRequest transfer = new TransferRequest();
    boolean prove = false;

    public ReceiveMessages(ImpInstantMessage itm) {
        this.itm = itm;
        LOGGER.info("The File Listener is listening an attemp");
    }

    public void fileTransferRequest(FileTransferRequest request) {
        itm.setReceiveMessage(transfer);
        prove = transfer.Receive(itm, request);
        if (prove == true) {
            itm.setRecBool(prove);
        }

    }
}
